package com.itsm.service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itsm.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT * FROM user where wxid = #{wxid}")
    User getUserById(String userid);


    //通过姓名获取人员信息
    @Select("SELECT * FROM user where name = #{name}")
    User getUserByName(String name);

    //获取上级企微id
    @Select("select sup_wxid  from user where wxid = #{userid}")
    String getUserSup(String userid);

    //it 审批人获取
//    @Select("select wxid from user where plant = (select plant from user where wxid = #{userid} ) and post = 2 and approve = 1 order by wxid limit 1 ")
    @Select("select name from user where approve = 1 order by wxid limit 1 ")
    String getItSup();

    @Select("select wxid from user where approve = 1 order by wxid limit 1 ")
    String getItId();
    //通过审批创建人企微id获取IT审批人信息
    @Select("select wxid from user where (plant = (select plant from user where wxid = #{userid} ) or plant_all = 1) and post = 2 ")
    List<String> getItSup1(String userid);

    @Select("select * from user where post != 0")
    List<User> getItEnUser();

    //获取全部的人员信息
    @Select("select * from user")
    List<User> getAllUser();

}
